class Solution {
public:
    int ans;
    int ret = 0;
    void serach(TreeNode* root){
        if(!root || ret != 0){
            return;
        }
        serach(root->right);
        ans--;
        if(ans == 0){
            ret = root->val;
            return;
        }
        serach(root->left);
    }
                                        
    int kthLargest(TreeNode* root, int k) {
        ans = k;
        serach(root);
        return ret;
    }
};
